package overriden;

class Animals {}

class Horses extends Animals {}

public class UseAnimals {
	public void doStuff(Animals a) {
		System.out.println("In the Animal version");
	}
	public void doStuff(Horses h) {
		System.out.println("In the Horse version");
	}
	
	public static void main (String [] args) {
		UseAnimals ua = new UseAnimals ();
		Animals animalObj = new Animals();
		Horses horseObj = new Horses();
		ua.doStuff(animalObj);
		ua.doStuff(horseObj);
		
		Animals animalRefToHorse = new Horses();
		ua.doStuff(animalRefToHorse); // the reference type (not the object type) determines which
									  // overloaded method is invoked.
	}
}
